package com.atguigu.datastream.day03;

import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * ClassName: Flink_01_Source_Collection
 * Package: com.atguigu.day03
 * Description:
 *              从集合读取数据
 * @Author ChenJun
 * @Create 2023/4/8 16:27
 * @Version 1.0
 */
public class Flink_01_Source_Collection {
    public static void main(String[] args) throws Exception {
        //1.获取Flink运行流环境
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        //2.设置并行度
        env.setParallelism(1);

        //3.从集合读取数据
        List<Integer> list = Arrays.asList(1, 2, 4, 5, 6, 7);

//        DataStreamSource<Integer> streamSource = env.fromCollection(list);

        //从参数读取
        DataStreamSource<Integer> streamSource = env.fromElements(1, 2, 34, 5, 6, 616, 161, 36, 4);
        //4.打印
        streamSource.print();

        //5.执行
        env.execute();



    }
}
